#include <iostream>
#include <string>
using namespace std;


int main(){
	int n,num,ansl;
	string s,ans;
	ans = "0";
	ansl = 1;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s.length() > ansl){
			ans = s;
			ansl = s.length();
			num = i+1;
			continue;
		}
		if(s.length() == ansl){
			for(int j=0;j<ansl;j++){
				if(s[j] > ans[j]){
//					cout<<s[j]<<">"<<ans[j]<<endl;
					ans = s;
					num = i+1;
					break;
				}
				if(s[j] < ans[j])
					break;
			}
		}
	}
	cout<<num<<endl<<ans;
}
